window.onload=function(){
	$(".devicelist").css("backgroundColor","#D83030").siblings().css("backgroundColor","#101113");
	//查询水机状态下拉框
	$(".deviceStatusCheckBox").click(function(event){
		event.stopPropagation();
		$(".deviceStatusCheckDropBox").show();
		$(".deviceStatusCheckDropBox a").unbind('click').click(function(){
			$(".deviceStatusCheckBox").val($(this).html());
			$(".deviceStatusCheckDropBox").hide();
		});
		$("body").unbind('click').click(function(){
			$(".deviceStatusCheckDropBox").hide();
		});
	});
	//搜索
	$(".searchList > a").click(function(){
		var device_code = $(".deviceCodeBox").val();
		var status = $(".deviceCheckBox").val();
		if(device_code=="%"){
			hint("非法输入，请正确输入编号！");
		}else{
			window.location.href='/admin/device/index?device_code='+device_code+'&status='+status;
		}
	});
	//根据绑定用户获取用户信息
	$(".bindUser a").click(function(){
		$(".infor_hint").html("");
		//显示弹框
		layui.use('layer', function(){
		  	var layer = layui.layer;
		  	layer.open({
				type: 1, 
				title: ['绑定用户信息', 'font-size:18px;'],
				area: ['800px', '500px'],
			  	content: $(".bindUserInforBox")
			}); 
		});
		$.ajax({
			url:"/admin/api/user/customer",
			type:"get",
			dataType:"json",
			data:{
				name:$(this).html()
			},
			success:function(data){
				if(data.status.errCode==0){
					$(".userName").html(data.data.customer.name);
					$(".userPhone").html(data.data.customer.phone);
					$(".IDNum").html(data.data.customer.sex);
					$(".address").html(data.data.customer.installation_address);
				}else if(data.status.errCode==2){
					$(".infor_hint").html("用户信息未完善。");
				}else{
					$(".infor_hint").html(data.status.message);
				}
			}
		})
		$(".userInfOkBtn").unbind('click').click(function(){
			window.location.reload();
		});
	});
}